

export default {
    namespaced: true,
    actions: {
        addPersonWang(context, value) {
            if (value.name.indexOf('王') == 0) {
                context.commit('ADDPERSONWANG', value);
            }
            else {
                alert('名字姓不为王');
            }

        }
    },
    mutations: {
        ADDPERSON: function (state, value) {
            console.log('mountation被用了');
            state.personList.push(value)
        },
        ADDPERSONWANG: function (state, value) {
            console.log('mountation被用了');
            state.personList.push(value)
        }
    },
    state: {
        personList: [{ name: '张三', id: '001' }, { name: '李四', id: '002' }]
    },
    getters: {
        Theperson(state) {
            return state.personList[0].name
        }
    }
}